#include<bits/stdc++.h>
using namespace std;
const int N=1e5;
int p[N];
int T,n,m,L,V;
struct car{
    int d,v,a;
}c[N];
struct node{
    int l,r;
}num[N];
bool cmp(node s,node t){
    if(s.r==t.r) return s.l<t.l;
    else return s.r<t.r;
}
int main(){
    ios::sync_with_stdio();
    cin.tie(),cout.tie();
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        memset(p,0,sizeof p);
        memset(c,0,sizeof c);
        memset(num,0,sizeof num);
        int ad=0,aj=0,az=0,ans=0,pos=0;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++){
            cin>>c[i].d>>c[i].v>>c[i].a;
            if(c[i].a>0) ad++;
            else if(c[i].a==0)  az++;
            else if(c[i].a<0) aj++;
        }
        for(int i=1;i<=m;i++)   cin>>p[i];
        if(ad==n||az==n){
            for(int i=1;i<=n;i++)
                if(p[m]-c[i].d>=0&&1LL*c[i].v*c[i].v+1LL*2*(p[m]-c[i].d)*c[i].a>V*V) ans++;
            if(ans==0) m++;
            cout<<ans<<" "<<m-1<<"\n";
        }
        else{
            for(int i=1;i<=n;i++){
                int rc,lr;
                if(c[i].a>0){
                    if(c[i].v<=V) rc=ceil(double((V*V-c[i].v*c[i].v)/(2*c[i].a*1.0)));
                    else rc=0;
                    if(rc+c[i].d>p[m]) continue;
                    if(c[i].v>V) rc=c[i].v;
                    lr=lower_bound(p+1,p+m+1,rc+c[i].d)-p;
                    num[++pos].r=m,num[pos].l=lr;
                    ans++;
                    //cout<<i<<" "<<lr<<" "<<num[pos].r<<"\n";
                }
                else if(c[i].a==0){
                    if(c[i].v<=V) continue;
                    if(c[i].d>p[m]) continue;
                    lr=lower_bound(p+1,p+m+1,c[i].d)-p;
                    num[++pos].r=m,num[pos].l=lr;
                    //cout<<i<<" "<<lr<<"\n";
                    ans++;
                }
                else if(c[i].a<0){
                    if(c[i].v<=V) continue;
                    if(c[i].d>p[m]) continue;
                    lr=lower_bound(p+1,p+m+1,c[i].d)-p;
                    rc=ceil(double((V*V-c[i].v*c[i].v)/(2*c[i].a*1.0)))+c[i].d;
                    int prc=lower_bound(p+1,p+m+1,rc)-p-1;
                    if(prc<lr) continue;
                    num[++pos].r=prc,num[pos].l=lr;
                    ans++;
                    //cout<<i<<" "<<lr<<" "<<prc<<"\n";
                }
            }
            cout<<ans<<" ";
            sort(num+1,num+pos+1,cmp);
           // for(int i=1;i<=pos;i++) cout<<num[i].l<<" "<<num[i].r<<"\n";
            //cout<<"\n";
            //cout<<"\n";
            int ll=0;ans=0;
            for(int i=1;i<=pos;i++){
                if(num[i].l<=ll) continue;
                ans++;
                ll=num[i].r;
                //cout<<ll<<" ";
            }
            //cout<<"\n";
            cout<<m-ans<<"\n";
        }
    }
}



